package com.shadow.demo.excel.demo.v2.vo;

import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.format.DateTimeFormat;
import com.alibaba.excel.annotation.format.NumberFormat;
import com.alibaba.excel.annotation.write.style.*;
import com.alibaba.excel.enums.poi.VerticalAlignmentEnum;
import com.shadow.demo.common.enums.excel.PersonalityEnum;
import com.shadow.demo.excel.demo.v2.converter.StringEnumsConverter;
import com.shadow.demo.excel.demo.v2.converter.annotation.EnumClass;
import lombok.Data;
import com.alibaba.excel.enums.poi.HorizontalAlignmentEnum;

import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * 导出对象
 * */
@Data
@HeadRowHeight(20)
@ContentRowHeight(20)
@ColumnWidth(20)
@HeadStyle(horizontalAlignment = HorizontalAlignmentEnum.CENTER,
        verticalAlignment = VerticalAlignmentEnum.CENTER
) // 表头样式
@ContentStyle(horizontalAlignment = HorizontalAlignmentEnum.CENTER,
        verticalAlignment = VerticalAlignmentEnum.CENTER
) // 内容样式
@ExcelIgnoreUnannotated // 只有加 @ExcelProperty 的字段才导出
public class EasyExcelExportVO {

    @ExcelProperty("ID")
    private String id;

    @ExcelProperty("姓名")
    private String name;

    @ExcelProperty("年龄")
    private Integer age;

    @NumberFormat("#.##")
    @ExcelProperty("资产")
    private BigDecimal assets;

    @EnumClass(PersonalityEnum.class)
    @ExcelProperty(value = "性格", converter = StringEnumsConverter.class)
    private String personality;

    @ColumnWidth(40)
    @ExcelProperty("密码")
    private String password;

    @ExcelProperty("创建时间")
    @DateTimeFormat("yyyy-MM-dd HH:mm")
    private LocalDateTime createTime;

    @ExcelProperty("修改时间")
    @DateTimeFormat("yyyy-MM-dd HH:mm")
    private LocalDateTime modifyTime;

    /* 无用字段 */
    private String nothing;
}
